package api.Calender;

import java.util.Calendar;
/*
* 已经淘汰的类，不建议使用，包括了SimpleDateFormat SimpleDateFormat，Date
* */
public class CalenderTest {
    public static void main(String[] args) {
        //创建一个日历对象
        Calendar cal = Calendar.getInstance();
        System.out.println(cal);
        //获取年
        int year = cal.get(Calendar.YEAR);
        System.out.println(year);
        //获取月
        int month = cal.get(Calendar.MONTH) + 1;
        System.out.println(month);
        //获取日
        int day = cal.get(Calendar.DAY_OF_MONTH);
        System.out.println(day);
        //获取时
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        System.out.println(hour);
        //获取分
        int minute = cal.get(Calendar.MINUTE);
        System.out.println(minute);
//        //修改日期
//        cal.set(Calendar.YEAR, 2020);
//        cal.set(Calendar.MONTH, 10);
//        cal.set(Calendar.DAY_OF_MONTH, 10);
//        System.out.println(cal.getTime());
        //获取今年第几天
        int dayOfYear = cal.get(Calendar.DAY_OF_YEAR);
        System.out.println(dayOfYear);

    }
}
